if __name__ == '__main__':
    import argparse
    import openslide

    parser = argparse.ArgumentParser(description='Get image of WSI and save it')
    parser.add_argument('--level', default=6, type=int, help='at which WSI level'
                    ' to obtain the mask, default 6')
    parser.add_argument('wsi_path', default=None, metavar='WSI_PATH', type=str,
                    help='Path to the WSI file')
    parser.add_argument('img_path', default=None, metavar='IMG_PATH', type=str,
                        help='Path to the outputimage file')
    args = parser.parse_args()

    slide = openslide.OpenSlide(args.wsi_path)
    img = slide.read_region((0, 0), args.level, slide.level_dimensions[args.level]).convert('RGB')
    img.save(args.img_path)